package cn.b.sky.mes.cm.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;

import cn.b.sky.common.model.ImeCommon;
import cn.b.sky.user.SecurityContextUtil;

public class ProcessModel extends ImeCommon implements Serializable {
  /** 
  * @Fields serialVersionUID :
  * @creator     :lidapeng
  */
  private static final long serialVersionUID = 1L;

  /**
   * 工艺编号
   */
  private String processCode;

  /**
   * 工作中心类型编号
   */
  private String workCenterTypeCode;

  /**
   * 工艺版本
   */
  private String processRev;

  /**
   * 生效时间
   */
  @DateTimeFormat(iso = ISO.DATE_TIME, pattern = "yyyy-MM-dd HH:mm:ss")
  private Date effectiveDate;

  /**
   * 失效时间
   */
  @DateTimeFormat(iso = ISO.DATE_TIME, pattern = "yyyy-MM-dd HH:mm:ss")
  private Date expirationDate;

  /**
   * 工作中心类型描述
   */
  private String typeText;

  /**
   * 描述
   */
  private String processText;

  /**
   * 锁定标志 0--正常，1--锁定
   */
  private Integer lockFlag = 0;

  /**
   * 发布标志 1--发布 0 -- 未发布
   */
  private Integer releaseFlag = 0;

  private List<ProcessOperation> operations = new ArrayList<ProcessOperation>();

  public String getProcessCode() {
    return StringUtils.upperCase(processCode);
  }

  public void setProcessCode(String processCode) {
    this.processCode = StringUtils.upperCase(processCode);
  }

  public String getWorkCenterTypeCode() {
    return workCenterTypeCode;
  }

  public String getProcessRev() {
    return processRev;
  }

  public void setProcessRev(String processRev) {
    this.processRev = processRev;
  }

  public Date getEffectiveDate() {
    return effectiveDate;
  }

  public void setEffectiveDate(Date effectiveDate) {
    this.effectiveDate = effectiveDate;
  }

  public Date getExpirationDate() {
    return expirationDate;
  }

  public void setExpirationDate(Date expirationDate) {
    this.expirationDate = expirationDate;
  }

  public String getTypeText() {
    return typeText;
  }

  public void setTypeText(String typeText) {
    this.typeText = typeText;
  }

  public void setWorkCenterTypeCode(String workCenterTypeCode) {
    this.workCenterTypeCode = workCenterTypeCode;
  }

  public String getProcessText() {
    return processText;
  }

  public void setProcessText(String processText) {
    this.processText = processText;
  }

  public Integer getLockFlag() {
    return lockFlag;
  }

  public void setLockFlag(Integer lockFlag) {
    this.lockFlag = lockFlag;
  }

  public Integer getReleaseFlag() {
    return releaseFlag;
  }

  public void setReleaseFlag(Integer releaseFlag) {
    this.releaseFlag = releaseFlag;
  }

  public List<ProcessOperation> getOperations() {
    return operations;
  }

  public void setOperations(List<ProcessOperation> operations) {
    this.operations = operations;
  }

  @Override
  public String getSiteCode() {
    String siteCode = super.getSiteCode();
    if (StringUtils.isBlank(siteCode)) {
      siteCode = SecurityContextUtil.getSiteCode();
    }
    return siteCode;
  }
}
